package kr.hkit.Powerjava.chapter26;

import java.sql.Connection;
import java.util.Scanner;

import kr.hkit.Powerjava.chapter26.common.ConnectionFactory;
import kr.hkit.Powerjava.chapter26.common.DbUtil;
import kr.hkit.Powerjava.chapter26.dto.Department;
import kr.hkit.Powerjava.chapter26.dto.Employee;
import kr.hkit.Powerjava.chapter26.service.AbsService;
import kr.hkit.Powerjava.chapter26.service.DepartmentService;
import kr.hkit.Powerjava.chapter26.service.EmployeeService;


public class TestMain {
	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		Connection connection = ConnectionFactory.getConnection();
		

		System.out.println("1.학생정보   2.부서정보");
		switch(sc.nextInt()){
			case 1:
				AbsService<Employee> empSvc = new EmployeeService(sc, connection);
				empSvc.prnMenu();
				break;
			case 2:
				AbsService<Department> deptSvc = new DepartmentService(sc, connection);
				deptSvc.prnMenu();
				break;
			default:
				DbUtil.close(connection);
		}		
		
/*		DepartmentDAO dao = new DepartmentDAO();
		try {
			ArrayList<Department> list = dao.listItems();
			for(Department d : list){
				System.out.println(d);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
//		Department d = new Department(6,"마케팅",8);
		
		try {
			dao.insertItem(d);
			System.out.println("삽입성공.");
		} catch (SQLException e) {
			System.err.println(e.getMessage()+ " : "+ e.getErrorCode());
		}
		
		try {
			d.setDeptname("교육");
			dao.updateItemByNo(d);
			System.out.println("갱신성공"+d);
		} catch (SQLException e) {
			e.printStackTrace();
		}*/
		
		
	/*	try {
			dao.deleteItemByNo(new Department(6));
			System.out.println("삭제성공.");
		} catch (SQLException e) {
			e.printStackTrace();
		}*/
		
		
	/*	Connection con = ConnectionFactory.getConnection();		
		System.out.println(con);*/
	}
}